package com.parkclouds.portal.common;

import java.io.Serializable;
import java.util.List;

import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Copyright: Copyright (c) 2019  zteits
 *
 * @ClassName: com.wx.miniapp.controller
 * @Description:
 * @version: v1.0.0
 * @author: atao
 * @date: 2019-03-28   21:11
 * Modification History:
 * Date         Author          Version      Description
 * ---------------------------------------------------------*
 * 2019-03-28      atao          v1.0.0          创建
 */
public class BaseController {



    public <T> DataGrid<T> returnDataGrid(PageInfo<T> pageInfo) {

        DataGrid<T> dataGrid = new DataGrid<T>();
        dataGrid.setTotal(pageInfo.getTotal());
        dataGrid.setRows(pageInfo.getList());

        return dataGrid;
    }

    protected class DataGrid<T> implements Serializable {

        private static final long serialVersionUID = 1L;
        /**
         * 总页数
         */
        private Long total;

        /**
         * 包含实际数据的数组
         */
        private List<T> rows;

        public Long getTotal() {
            return total;
        }

        public void setTotal(Long total) {
            this.total = total;
        }

        public List<T> getRows() {
            return rows;
        }

        public void setRows(List<T> rows) {
            this.rows = rows;
        }

    }

}
